namespace MLSharp.Clustering
{
	/// <summary>
	/// A knowledge frontier as found by <see cref="KnowledgeFrontierDiscovery"/>.
	/// </summary>
	public class KnowledgeFrontier : IKnowledgeFrontier
	{
		#region Properties

		/// <summary>
		/// The cluster node that is the frontier.
		/// </summary>
		public IClusterNode Node { get; set; }

		/// <summary>
		/// The standard deviation in the accuracy of instances in the 
		/// knowledge frontier.
		/// </summary>
		public double AccuracyStdDev { get; set; }

		/// <summary>
		/// The average of the accuracies of the instances in the 
		/// knowledge frontier.
		/// </summary>
		public double AverageAccuracy { get; private set; }

		#endregion

		#region Public Constructors

		/// <summary>
		/// Creates a knowledge frontier for the specified node.
		/// </summary>
		/// <param name="node"></param>
		/// <param name="average">The average accuracy.</param>
		/// <param name="stdDev">The accuracy standard deviation.</param>
		public KnowledgeFrontier(IClusterNode node, double average, double stdDev)
		{
			Node = node;
			AverageAccuracy = average;
			AccuracyStdDev = stdDev;
		}

		/// <summary>
		/// Creates an empty frontier.
		/// </summary>
		public KnowledgeFrontier()
		{
			
		}

		#endregion

		#region Overriden Methods 

		/// <summary>
		/// Returns a string describing the frontier.
		/// </summary>
		/// <returns></returns>
		public override string ToString()
		{
			int? nodeId = null;

			if (Node != null)
				nodeId = Node.NodeId;

			return string.Format("{{NodeId: {0}, Average: {1}, StdDev: {2}}}", nodeId, AverageAccuracy, AccuracyStdDev);
		}

		#endregion
	}
}